﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace DevExpress.Demos.DemoCenter
{
    public partial class JudgeControl : DevExpress.XtraEditors.XtraUserControl
    {
        LabelEx lblEx = null;
        MyPictureBox myPictureBox = null;
        CheckEdit checkEdit = null;

        public JudgeControl()
        {
            InitializeComponent();
            //添加控件
            AddQuestionsControl();
        }


        /// <summary>
        /// 添加控件
        /// </summary>
        public void AddQuestionsControl()
        {
            lblEx = new LabelEx();
            lblEx.AutoResizeParent = false;
            lblEx.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            lblEx.Location = new System.Drawing.Point(19, 9);
            lblEx.Name = "lblEx";
            lblEx.Width = 560;
            lblEx.Text = "一、我国人民之所以是国家的主人，根本原因在于我国建立生产资料公有制，个人利益和国家利益在根本上是一致的。";
            lblEx.Click += new EventHandler(lblEx_Click);
            this.Controls.Add(lblEx);

            myPictureBox = new MyPictureBox();
            myPictureBox.Location = new System.Drawing.Point(19, lblEx.Location.Y+lblEx.Height+5);
            myPictureBox.Name = "myPictureBox";
            myPictureBox.Properties.Appearance.BackColor = System.Drawing.Color.Transparent;
            myPictureBox.Properties.Appearance.Options.UseBackColor = true;
            myPictureBox.Properties.Appearance.Options.UseBorderColor = true;
            myPictureBox.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
            myPictureBox.Size = new System.Drawing.Size(200, 160);
            myPictureBox.MouseEnter += new System.EventHandler(this.myPictureBox3_MouseEnter);
            myPictureBox.MouseLeave += new System.EventHandler(this.myPictureBox3_MouseLeave);
            myPictureBox.Image = Image.FromFile(@"form-main-bg.png");
           
            this.Controls.Add(myPictureBox);


            checkEdit = new CheckEdit();
            checkEdit.Location = new System.Drawing.Point(myPictureBox.Location.X+myPictureBox.Width+5, myPictureBox.Location.Y+(myPictureBox.Height-checkEdit.Height)/2);
            checkEdit.Name = "checkEdit";
            checkEdit.Properties.Appearance.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            checkEdit.Properties.Appearance.Options.UseFont = true;
            checkEdit.Properties.Caption = "错误";
            checkEdit.Size = new System.Drawing.Size(54, 25);
            checkEdit.CheckStateChanged += new System.EventHandler(this.checkEdit1_CheckStateChanged);

            this.Controls.Add(checkEdit);
            this.Height = myPictureBox.Location.Y + myPictureBox.Height;
        }

        void lblEx_Click(object sender, EventArgs e)
        {
            this.lblEx.Parent.Parent.Focus();
        }

        private void myPictureBox3_MouseEnter(object sender, EventArgs e)
        {
            this.myPictureBox.Properties.Appearance.BorderColor = Color.FromArgb(255, 188, 98);
            this.myPictureBox.Cursor = Cursors.Hand;
        }

        private void myPictureBox3_MouseLeave(object sender, EventArgs e)
        {
            this.myPictureBox.Properties.Appearance.BorderColor = Color.White;
        }

        private void memoEdit1_MouseEnter(object sender, EventArgs e)
        {
            //this.memoEdit1.Properties.AppearanceReadOnly.BorderColor = Color.FromArgb(255, 188, 98);
        }

        private void memoEdit1_MouseLeave(object sender, EventArgs e)
        {
            //this.memoEdit1.Properties.AppearanceReadOnly.BorderColor = Color.White;
        }


        private void SelectorControl_Click(object sender, EventArgs e)
        {
            this.Parent.Focus();
        }

        private void checkEdit1_CheckStateChanged(object sender, EventArgs e)
        {
            if (this.checkEdit.Checked)
            {
                this.checkEdit.Text = "正确";
            }
            else
            {
                this.checkEdit.Text = "错误";
            }
        }


    }
}
